﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Raise3000.Code
{
    public class PlayerTemplate
    {
        // Fields
        private long templateId_ = -1;
        private string playerTemplateName_ = "";
        private string description_ = "";

        List<StatisticalAttribute> attributes_ = new List<StatisticalAttribute>();

        public long Id
        {
            get
            {
                return templateId_;
            }
            set
            {
                templateId_ = value;
            }
        }

        public string Name
        {
            get
            {
                return playerTemplateName_;
            }
            set
            {
                playerTemplateName_ = value;
            }
        }

        public string Description
        {
            get
            {
                return description_;
            }
            set
            {
                description_ = value;
            }
        }

        public PlayerTemplate()
        {
        }

        public PlayerTemplate(string playerTemplateName)
        {
            playerTemplateName_ = playerTemplateName;
        }

        // add, remove, find, modify attributes
        public void AddAttribute(StatisticalAttribute attribute)
        {
            if (FindAttributeByName(attribute.Name) == null)
            {
                attributes_.Add(attribute);
            }
        }

        public void ModifyAttribute(string attributeName, double newValue)
        {
            StatisticalAttribute sa = FindAttributeByName(attributeName);
            if (sa != null)
            {
                sa.Value = newValue;
            }
        }

        public StatisticalAttribute FindAttributeByName(string attributeName)
        {
            return attributes_.Find(a => a.Name == attributeName);
        }
    }
}
